package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import android.util.Log;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IAppHeadPage;
import com.itboye.mengwu.data.interfaces.ILunBo;
import com.itboye.mengwu.data.model.AppHeadPage;
import com.itboye.mengwu.data.model.LunBoModel;
import com.itboye.mengwu.data.repository.HomePageResitory;
import com.itboye.mengwu.data.repository.LunBoRepository;

public class HomePagePresenter extends BasePresenter implements IAppHeadPage {
	public static final String BannerSuccessEvent = MainPresenter.class
			.getName() + "_Banner_success";
	public static final String BannerFailEvent = MainPresenter.class.getName()
			+ "_Banner_failure";
	public static final String HomeQuerySuccessEvent = MainPresenter.class
			.getName() + "_HomeQuerySuccessEvent";
	public static final String HomeQueryFailEvent = MainPresenter.class
			.getName() + "_HomeQueryFailEvent_failure";
	public static final String LunBoFailEvent = MainPresenter.class.getName()
			+ "_LunBoFailEvent_failure";
	public static final String LunBoSuccessEvent = MainPresenter.class
			.getName() + "_LunBoSuccessEvent_Success";

	public HomePagePresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(AppHeadPage model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(AppHeadPage model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(AppHeadPage model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(AppHeadPage model) {
		// TODO Auto-generated method stub
		IAppHeadPage banner = new HomePageResitory(new ICompleteListener() {

			@Override
			public void success(ResultEntity result) {
				// TODO Auto-generated method stub
				result.setEventTag(Tag_Success);
				result.setEventType(HomeQuerySuccessEvent);
				setChanged();
				notifyObservers(result);
			}

			@Override
			public void failure(ResultEntity result) {
				// TODO Auto-generated method stub
				result.setEventTag(Tag_Error);
				result.setEventType(HomeQueryFailEvent);
				setChanged();
				notifyObservers(result);
			}
		});
		banner.getInfo(model);// (phoneNumber,codeType);
	}

	@Override
	public List<AppHeadPage> query(AppHeadPage model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void appHead(String pageId) {
		// TODO Auto-generated method stub
		IAppHeadPage banner = new HomePageResitory(new ICompleteListener() {

			@Override
			public void success(ResultEntity result) {
				// TODO Auto-generated method stub
				Log.v("MainPresenter", "lunbo success");
				result.setEventTag(Tag_Success);
				result.setEventType(BannerSuccessEvent);
				setChanged();
				notifyObservers(result);
			}

			@Override
			public void failure(ResultEntity result) {
				// TODO Auto-generated method stub
				Log.v("MainPresenter", "lunbo fail");
				result.setEventTag(Tag_Error);
				result.setEventType(BannerFailEvent);
				setChanged();
				notifyObservers(result);
			}
		});
		banner.appHead(pageId);// (phoneNumber,codeType);
	}

	@Override
	public void lunbo(int posion) {
		// TODO Auto-generated method stub
		IAppHeadPage banner = new HomePageResitory(new ICompleteListener() {

			@Override
			public void success(ResultEntity result) {
				// TODO Auto-generated method stub
				Log.v("MainPresenter", "lunbo success");
				result.setEventTag(Tag_Success);
				result.setEventType(LunBoSuccessEvent);
				setChanged();
				notifyObservers(result);
			}

			@Override
			public void failure(ResultEntity result) {
				// TODO Auto-generated method stub
				Log.v("MainPresenter", "lunbo fail");
				result.setEventTag(Tag_Error);
				result.setEventType(LunBoFailEvent);
				setChanged();
				notifyObservers(result);
			}
		});
		banner.lunbo(posion);// (phoneNumber,codeType);
	}
}
